<?php
namespace app\admin\controller;
use phpDocumentor\Reflection\DocBlock\Tags\Var_;
use think\Paginator;
use think\Db;

class Admintoken extends Base
{
    public function token_list()
    {
        //给当前页面seo变量赋值
        $this->view->assign('title','环信列表');
        $this->view->assign('keywords','php.cn');
        $this->view->assign('desc','中小学教育管理平台');
        //显示用户信息
        $attr = Db::table('hxconfig')->select();
        $datetime = $attr['0']['updateTime'];
//        var_dump($attr);
//        die();
        $id = $attr['0']['id'];
        $datas =  date("Y-m-d H:i",$datetime);
        //渲染到页面
        $this->assign('attr',$attr);
        $this->assign('datas',$datas);
        $this->assign('id',$id);
        return $this->fetch();

    }
    //修改信息表展示
    public function token_edit()
    {
        //设置当前页面的seo模板变量
        $this->view->assign('title','编辑环信');
        $this->view->assign('keywords','');
        $this->view->assign('desc','中小学教育管理平台');

        $attr = Db::table('hxconfig')->select();
        $att = $attr['0'];
        $attDate = date("Y-m-d H:i",$att['updateTime']);

        //渲染到页面
        $this->assign('att',$att);
        $this->assign('attDate',$attDate);
        return $this->fetch();
    }
    //修改信息
    public function token_edits(){
        $client_id=input('client_id');
        $client_secret=input('client_secret');
        $org_name=input('org_name');
        $app_name=input('app_name');
        $access_token=input('access_token');
        $updatetime = time();
        $date=array(
                'client_id'=>$client_id,
                'client_secret'=>$client_secret,
                'org_name'=>$org_name,
                'app_name'=>$app_name,
                'access_token'=>$access_token,
                'updateTime'=>$updatetime,
           );
      $su =   Db::table('hxconfig')->where(array('id'=>1))->update($date);
        //设置返回数据
        $status = 0;
        $message = '更新失败,请检查';

        if($su == true){
            $status = 1;
            $message = '更新成功';
        }
        return ['status'=>$status,'message'=>$message];
    }
}
